Skip to main content

Opening New Ports

In the directory /home/errityr, there is a bash script which will permit the opening of ports and forwarding them to a particular VM.

You can find all relevant scripts in Scripts

#!/bin/bash

if [[ $# -ne 2 ]]; then
echo "Usage: $0 <PORT> <DestIp>"
exit 1
fi

port="$1"
server="$2"

iptables -t nat -A PREROUTING -p tcp -d 136.243.40.234 --dport "$port" -i vmbr0 -j DNAT --to-destination "$server:$port"
./save_iptables.sh

For example to open the port 22100 for the webserver VM I would run:

sudo ./open_port.sh 22100 10.0.0.0 

This also persists those changes by running save_iptables.sh

sudo iptables-save > /etc/iptables/rules.v4